<template>
	<!--批量-->
	<view class="page-content">
		<scroll-view class="page-body" :scroll-top="scrollTop" scroll-y="true" @scrolltolower="loadmore()">
			<!--图片批量-->
			<view class="body-top">
				<block v-for="(item,index) in objdata.list" :key="index">
					<view class="body-top-li" :style="{width:img_width + 'px'}" v-if="item.select">
						<image class="top-li-img" :src="item.url"
							:style="{width:img_width + 'px',height:img_width + 'px'}"></image>
						<image @click.stop="todel(index,item.select)" class="top-li-icon" :src="$mAssetsPath.icon_sc6">
						</image>
					</view>
				</block>
				<image @click="toadd" class="body-top-add" :src="$mAssetsPath.icon_add2"
					:style="{width:img_width + 'px',height:img_width + 'px'}"></image>
			</view>

			<!--产品图片数据-->
			<view class="body-box">
				<product-num-add :obj="objdata" @choose="choose" @confirm="confirm_sel" @sel_mat="sel_mat"  @delItem="delItem" @delItem0="delItem0"
					@delItem2="delItem2" @rednum2="rednum2" @rednum1="rednum1" @addnum2="addnum2" @addnum1="addnum1" @add_pro="add_pro"
					@add_pro2="add_pro2" :pageType="selType"></product-num-add>
				<!-- <block v-for="(item,index) in objdata.datalist" :key="index">
					<view class="body-box-li" @click="selnum(index,item.id)">
						<product-num-add :obj="item" @choose="choose" @confirm="confirm_sel" @sel_mat="sel_mat"
							@rednum2="rednum2" @rednum1="rednum1" @addnum2="addnum2" @addnum1="addnum1" @add_pro="add_pro"
							:pageType="selType"></product-num-add>
					</view>
				</block> -->
				<!--增加-->
				<image class="li-texture-bot3" @click="add_pro('0','0','1')" :src="$mAssetsPath.icon_add_but2"></image>
			</view>

		</scroll-view>
		<view class="page-foot">
			<view class="submit" @tap="confirm()">保存</view>
		</view>
		<w-popup :show="showtip" :type="type1" @change="change1">
			<view class="w-tip">
				<view class="w-con">
					<view class="w-con-txt" v-if="selType === 'pop'" @click="toPop">POP画册</view>
					<!-- <view class="w-con-txt" @click="photoAlbum">手机相册</view> -->
					<view class="w-con-cen" @click="cancel('tip')">取消</view>
				</view>
			</view>
		</w-popup>
		<!-- 下拉框 -->
		<u-popup class="popup-content" mode='bottom' border-radius="16" v-model="show">
			<view class="header">
				<view class="title">{{poptype==='1'?'设置一级关联：':poptype==='2'?'设置二级关联：':'设置三级关联'}}</view>
			</view>
			<scroll-view class="body" scroll-y="true">
				<template v-if="list2.length>0">
					<block v-for="(item,index) in list2" :key="index">
						<view class="box" @click="checks(item.id,item.top_id,item.checked)">
							<view class="box-name" :style="{color:item.checked?'#198FFF':'#999'}">{{item.name}}</view>
							<view class="box-icon">
								<image class="box-icon-dagou" v-if="item.checked" :src="$mAssetsPath.icon_dagou"></image>
							</view>
						</view>
					</block>
				</template>
				<template v-else>
					<view class="box-nodata">暂无数据</view>
				</template>
			</scroll-view>
			<view @tap="cancel" hover-class="none" class="footer">取消</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		unique
	} from '@/common/util.js';
	import wSelSearch from '@/components/w-sel-logo/w-sel-search.vue'; //标题
	import loadMore from '@/components/uni-load-more/load-more.vue';
	import productNumAdd from '@/pages/components/product_num_add-li.vue';
	import wPopup from '@/components/w-popup/w-popup2.vue';

	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
		getProductAttrLists, //pro-筛选列表
		getProductCodingLists, //pop - prop编码列表
		saveTaskDatas, //保存
		getOssUploadsParams,

	} from '@/common/api.js';
	export default {
		components: {
			loadMore,
			productNumAdd,
			wSelSearch,
			wPopup
		},
		data() {
			return {
				scrollTop: 0,
				system: {
					w: 0,
					h: 0,
					scale: 1,
					systemScale: 1,
				},
				objdata: {
					id: 1,
					image: '/static/data-img/img.jpg',
					title: '任务名任务名任务名任务名',
					flow: '',
					list: [],
					datalist: [],
				},
				list2: [],
				system: {
					w: 0,
					h: 0,
					scale: 1,
					systemScale: 1,
				},
				sel_index: 0, //选择当前项
				sel_ind: 0, //选择当前项
				sel_id: 0,
				showtip: false, //是否显示弹窗1
				content1: '顶部弹 popup',
				type1: '', //弹窗显示方式
				show: false,
				poptype: 1, //弹窗类型

				pageType: '', //pro-画册   pop-pop  prop-道具 
				selType: '',
				imglist: [],
				params: {
					company_id: '',
					top_id: '',
					type: ''
				},
				json: {
					task_id: '',
					company_id: '',
					task_data: []
				},
				sourceType: ['album', 'camera'],
				chooseNum: 9,
				addType:''
			}
		},
		computed: {
			...mapGetters(['companyInfo', 'userInfo']),
			img_width() {
				return (this.system.w - 65) / 6;
			},
		},
		onShow() {
			uni.getSystemInfo().then(res => {
				let system = res[1]
				this.system.scale = 667 / 375 //按照苹果留 375*667比例 其他型号手机等比例缩放 显示
				this.system.systemScale = system.windowWidth / 375 //按照苹果留 375*667比例 其他型号手机等比例缩放 显示
				this.system.w = system.windowWidth;
				this.system.h = system.windowHeight;
			})
			this.getdata();
			//this.getdata2();
		},
		onLoad(option) {
			console.log(222, option)
			this.params.company_id = this.companyInfo.id;
			this.json.company_id = this.companyInfo.id;

			if (!!option.pageType) {
				this.pageType = option.pageType
			}
			if (option.task_id) {
				this.json.task_id = parseInt(option.task_id);
			}
			if (option.selType) {
				this.selType = option.selType
			}
			if (option.imglist) {
				this.objdata.list = JSON.parse(option.imglist)
			}
			if(option.addType){
				this.addType = option.addType;
			}
		},
		onNavigationBarButtonTap(e) {
			console.log(123, e)
			if (e.index === 0) {
				this.content1 = 'center'
				this.type1 = 'bottom';
				this.showtip = !this.showtip;
			}
		},
		methods: {
			unique,
			//初始化数据
			/* getdata2() {
				let _self = this;
				if (this.selType === 'pop') { //pop
					this.params.type = 1;
					this.params.top_id = 0;
					getProductCodingLists(this.params).then(res => {
						if (res.code === 2000) {
							let pageobj = res.data;
							if (pageobj && pageobj.length > 0) {
								pageobj.forEach((item, index) => {
									this.$set(item, 'data', Array);
									this.$set(item, 'checked', false);

									let texture = []
									this.params.top_id = item.id;
									getProductCodingLists(_self.params).then(res2 => {
										if (res2.code === 2000) {
											_self.$nextTick(() => {
												item.data = res2.data;
												if (res2.data && res2.data.length > 0) {
													res2.data.forEach(item2 => {
														if (item2.has_next) {
															_self.$set(item2,'data',Array);
															_self.$set(item2,'number', 0);
															texture.push(item2.texture_name); //材质

															getProductCodingLists({
																company_id: _self.params.company_id,
																top_id: item2.id,
																type: _self.params.type}).then(res3 => {
																item2.data =res3.data;
																if (item2.data && item2.data.length >0) {item2.data.forEach(item3 => {
																	texture.push(item3.texture_name) //材质
																	_self.$set(item3,'number',0);
																	console.log(11111,texture)
																		}
																	)
																}
															})
														}
													})
												}
											})
										}
									})
									this.$set(item, 'texture', texture);
								})
							}
							//this.list2 = pageobj;
							console.log(22222, this.list2)
						}
					})
				} else if (this.selType === 'prop') { //prop

				}
			}, */
			resdata(item){
				console.log(2222,item)
				if(item && item.length>0){
					item.forEach(item=>{
						this.objdata.list.push(item)
					})
				}
			},
			//删除一级
			delItem0(index, ind) {
				console.log(1111,index, ind,this.objdata.datalist)
				if (this.objdata.datalist && this.objdata.datalist.length > 0) {
					this.objdata.datalist.forEach((item, i) => {
						let list = this.objdata.datalist
						delete list[index]
						this.objdata.datalist = list.filter(Boolean)
					})
				}
			},
			//删除一级
			delItem(index, ind) {
				console.log(1111,index, ind,this.objdata.datalist)
				if (this.objdata.datalist && this.objdata.datalist.length > 0) {
					this.objdata.datalist.forEach((item, i) => {
						if (index === i) {
							let list = item.data
							delete list[ind]
							item.data = list.filter(Boolean)
						}
					})
				}
			
			},
			//删除二级
			delItem2(index, index2, index3) {
				console.log(1111,index, index2, index3)
				if (this.objdata.datalist && this.objdata.datalist.length > 0) {
					this.objdata.datalist.forEach((item, i) => {
						if (index === i) {
							if (item.data && item.data.length > 0) {
								item.data.forEach((item2, iii) => {
									if (index2 === iii) {
										let list = item2.data
										delete list[index3]
										item2.data = list.filter(Boolean)
							
									}
								})
							}
						}
					})
				}
				console.log(11111, this.objdata.objlist)
			},
			//增加0-级属性
			add_pro(index, top_id, poptype) {
				console.log(555, index, top_id, poptype)
				console.log(555, this.objdata)
				this.poptype = poptype;
				let _self = this;
				this.sel_index = index;
				this.show = true;
				if (this.selType === 'pop') { //pop
					this.params.type = 1;
				} else if (this.selType === 'prop') {
					this.params.type = 2;
				}
				if (this.poptype === '1') {
					this.params.top_id = 0;
					getProductCodingLists(_self.params).then(res => {
						if (res.code === 2000) {
							this.list2 = res.data;
							if (this.list2 && this.list2.length > 0) {
								this.list2.forEach(item => {
									this.$set(item, 'checked', false);
									if (this.objdata.datalist && this.objdata.datalist.length > 0) {
										this.objdata.datalist.forEach(item2 => {
											if (item2.checked && item2.name === item.name) {
												item.checked = true
											}
										})
									}
								})
							}
						}
					})
				} else if (this.poptype === '2') {
					this.params.top_id = top_id;
					getProductCodingLists(_self.params).then(res2 => {
						if (res2.code === 2000) {
							this.list2 = res2.data;
							if (this.list2 && this.list2.length > 0) {
								this.list2.forEach(item => {
									this.$set(item, 'checked', false);
									if (this.objdata.datalist && this.objdata.datalist.length > 0) {
										this.objdata.datalist.forEach(item2 => {
											if (item2.data && item2.data.length > 0) {
												item2.data.forEach(item3 => {
													if (item3.checked && item3.name === item.name) {
														item.checked = true
													}
												})
											}
										})
									}
								})
							}
						}
					})
				}
			},
			add_pro2(index, ind, top_id, poptype) {
				console.log(555, index, ind, top_id, poptype)
				this.poptype = poptype;
				let _self = this;
				this.sel_index = index;
				this.sel_ind = ind;
				this.show = true;
				if (this.poptype === '3') {
					if (this.selType === 'pop') { //pop
						this.params.top_id = top_id;
						getProductCodingLists(_self.params).then(res2 => {
							if (res2.code === 2000) {
								this.list2 = res2.data;
								if (this.list2 && this.list2.length > 0) {
									this.list2.forEach(item => {
										if (this.objdata.datalist && this.objdata.datalist.length > 0) {
											this.objdata.datalist.forEach(item2 => {
												if (item2.data && item2.data.length > 0) {
													item2.data.forEach(item3 => {
														if (item3.data && item3.data.length > 0) {
															item3.data.forEach(item4 => {
																if (item4.checked && item4.name === item.name) {
																	item.checked = true
																}
															})
														}
													})
												}
											})
										}
									})
								}
							}
						})
					}
				}
			},
			//弹窗-下拉框选择
			checks(id, top_id, checked) {
				console.log(123, id, top_id)
				console.log(4444, this.objdata)
				console.log(5555, this.list2)
				let _self = this;
				if (!checked) {
					if (this.poptype === '1') {
						if (this.list2 && this.list2.length > 0) {
							this.list2.forEach(item => {
								if (item.id === id) {
									item.checked = !checked;
									let data = [];
									let texture = [];
									this.$set(item, 'data', data);
									this.$set(item, 'texture', texture);
									this.$set(item, 'product_coding_id', item.id);
									this.objdata.datalist.push(item);
									/* if(this.objdata.data && this.objdata.data.length>0){
										this.objdata.data.forEach(item2=>{
											
										})
									} */
								}
							})
						}
					} else if (this.poptype === '2') {
						if (this.objdata.datalist && this.objdata.datalist.length > 0) {
							this.objdata.datalist.forEach((item, i) => {
								if (i === this.sel_index) {
									if (this.list2 && this.list2.length > 0) {
										this.list2.forEach(item2 => {
											if (item2.id === id) {
												item2.checked = !checked;
												_self.$set(item2, 'product_coding_id', item2.id);
												item.data.push(item2)
												item.texture.push(item2.texture_name);
												if (item.data && item.data.length > 0) {
													item.data.forEach((item3, ii) => {
														let data = [];
														if (item.data.length - 1 == ii) {
															this.$set(item3, 'data', data);
															this.$set(item3, 'number', 0);
														}
													})
												}
											}
										})
									}
								}
							})
						}

					} else if (this.poptype === '3') {
						if (this.objdata.datalist && this.objdata.datalist.length > 0) {
							this.objdata.datalist.forEach((item, i) => {
								if (i === this.sel_index) {

									if (item.data && item.data.length > 0) {
										item.data.forEach((item2, ii) => {
											if (ii === this.sel_ind) {
												if (this.list2 && this.list2.length > 0) {
													this.list2.forEach(item3 => {
														_self.$set(item3, 'number', 0);
														_self.$set(item3, 'product_coding_id',item3.id);

														if (item3.id === id) {
															item3.checked = !checked;
															/* let data = [];
															this.$set(item3, 'data', data); */
															item2.data.push(item3)
															item.texture.push(item3.texture_name)
														}
													})
												}
											}
										})
									}
								}
							})
						}
					}
				}

				this.show = false;
			},
			//获取数据
			getdata() {
				if (this.objdata.list && this.objdata.list.length > 0) {
					this.objdata.list.forEach((item, ii) => {
						this.$set(item, 'select', true)
					})
				}
				//下拉框-关联-数据
				if (this.list2 && this.list2.length > 0) {
					this.list2.forEach(item => {
						this.$set(item, 'checked', false)
					})
				}
			},
			//删除
			todel(index, select) {
				if (this.objdata.list && this.objdata.list.length > 0) {
					this.objdata.list.forEach((item, ii) => {
						if (ii === index) {
							item.select = !select;
						}
					})
				}
			},
			toadd() {
				let _self = this;
				if (this.selType === 'pop') {
					this.content1 = 'center'
					this.type1 = 'bottom';
					this.showtip = !this.showtip;
				} else if (this.selType === 'prop') {
					uni.chooseImage({
						count: this.chooseNum,
						sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
						sourceType: this.sourceType,
						success: (tempFilePaths) => {

							console.log('选择文件：', tempFilePaths)
							uni.showLoading({
								title: '上传中'
							});
							let uploadImgs = [];
							getOssUploadsParams().then(res => {
								if (res.code === 2000) {
									tempFilePaths.tempFilePaths.forEach((item, index) => {
										uploadImgs.push(new Promise((resolve, reject) => {
											let file_path = item;
											let filename = tempFilePaths.tempFiles[index];
											let suffix = "." + _self.getCaption(filename.path);
											let file_name = new Date().getTime() + Math.random().toString(36).substring(3,20) + suffix
											console.log(333333, file_name,filename)
											//上传图片接口
											uni.uploadFile({
												url: res.data.host,
												filePath: file_path,
												fileType: 'image',
												name: 'file',
												formData: {
													name: file_path,
													'key': res.data.dir + file_name,
													'policy': res.data.policy,
													'OSSAccessKeyId': res.data.accessid,
													'success_action_status': '200',
													//让服务端返回200,不然，默认会返回204
													'signature': res.data.signature,
												},
												success: (res2) => {
													resolve(res2);
													console.log(
														'uploadImage success, res is:',
														res2)
													let img_list = {
														url: ''
													}
													img_list.url = res.data.host + '/' + res.data.dir + file_name;
													_self.objdata.list.push(img_list)
													console.log(666,img_list)
													_self.getdata();
													//_self.$forceUpdate() //二维数组，开启强制渲染
												},
												fail: (err) => {
													console.log(err);
													reject(err);
												},
												complete: () => {
													//uni.hideLoading();
												}
											});
										}))
										Promise.all(uploadImgs).then((
											results) => { //执行所有需请求的接口
												uni.hideLoading();
											})
											.catch((res3, object) => {
												uni.hideLoading();
											});
									})

								}
							})
						}
					});
				}
			},
			getCaption(obj) {
				var index = obj.lastIndexOf("\.");
				obj = obj.substring(index + 1, obj.length);
				return obj;
			},
			//跳转pop画册
			toPop() {
				/* uni.navigateTo({
					url: '/pages/picBook/picBookList?type=1&pageStatu=2&userType=system'
				}) */
				uni.navigateTo({
					url: `/pages/picBook/picBookList?task_id=${this.json.task_id}&pageType=pro&pageStatu=2&userType=system&selType=pop&&addType=popadd`
				})
				this.showtip = false;
			},
			//下弹窗
			photoAlbum() {
				uni.chooseImage({
					count: this.chooseNum,
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: this.sourceType,
					success: (res) => {

						uni.navigateTo({
							url: `/pages/picBook/createTask?pageType=pop`
						})

						//console.log('tempFiles', res)
						if (this.action == '') { //未配置上传路径
							this.$emit("chooseSuccess", res.tempFilePaths);
						} else {
							if (this.compress && (res.tempFiles[0].size / 1024 >
									1025)) { //设置了需要压缩 并且 文件大于1M，进行压缩上传
								this.imgCompress(res.tempFilePaths);
							} else {
								this.imgUpload(res.tempFilePaths);
							}
						}
					}
				});
			},
			//修改图片
			replace_img(id) {

			},
			//跳转流程页面
			tolinkflow(id) {
				uni.navigateTo({
					url: `/pages/flow/flowlist?id=${id}`
				})
			},
			//材质选择
			choose(index) {
				if (this.list && this.list.length > 0) {
					this.list.forEach((item, ind) => {
						if (ind === index) {
							item.statu = !item.statu
						}
					})
				}
			},
			//材质弹窗
			sel_mat() {
				if (this.list && this.list.length > 0) {
					this.list.forEach((item, ind) => {
						this.$set(item, 'statu', false);
					})
				}
			},
			//确认材质选择
			confirm_sel(list, index) {
				console.log(555, list)
				if (this.objdata.datalist && this.objdata.datalist.length > 0) {
					this.objdata.datalist.forEach((item, i) => {
						if (this.sel_index === i) {
							if (item.data && item.data.length > 0) {
								item.data.forEach((item2, ii) => {
									if (index === ii) {
										item2.texture = list;
									}
								})
							}
						}
					})
				}
			},
			//筛选项
			selnum(index, id) {
				console.log(12, index, id)
				this.sel_index = index;
				this.sel_id = id;
			},
			rednum1(ind, index) {
				if (this.objdata.datalist && this.objdata.datalist.length > 0) {
					this.objdata.datalist.forEach((item, i) => {
						if (ind === i) {
							if (item.data && item.data.length > 0) {
								item.data.forEach((item2, ii) => {
									if (index === ii) {
										if (item2.number > 0) {
											item2.number -= 1
										}
									}
								})
							}
						}
					})
				}
			},
			addnum1(ind, index) {
				console.log(888, ind, index, this.objdata.datalist)
				if (this.objdata.datalist && this.objdata.datalist.length > 0) {
					this.objdata.datalist.forEach((item, i) => {
						if (ind === i) {
							if (item.data && item.data.length > 0) {
								item.data.forEach((item2, ii) => {
									if (index === ii) {
										item2.number += 1
									}
								})
							}
						}
					})
				}
				console.log(888, ind, index, this.objdata.datalist)
			},
			rednum2(ind, index, index2) {
				if (this.objdata.datalist && this.objdata.datalist.length > 0) {
					this.objdata.datalist.forEach((item, i) => {
						if (ind === i) {
							if (item.data && item.data.length > 0) {
								item.data.forEach((item2, ii) => {
									if (index === ii) {
										if (item2.data && item2.data.length > 0) {
											item2.data.forEach((item3, iii) => {
												if (index2 === iii) {
													if (item3.number > 0) {
														item3.number -= 1
													}
												}
											})
										}
									}
								})
							}
						}
					})
				}
			},
			addnum2(ind, index, index2) {
				console.log(999, ind, index, index2)
				if (this.objdata.datalist && this.objdata.datalist.length > 0) {
					this.objdata.datalist.forEach((item, i) => {
						if (ind === i) {
							if (item.data && item.data.length > 0) {
								item.data.forEach((item2, ii) => {
									if (index === ii) {
										if (item2.data && item2.data.length > 0) {
											item2.data.forEach((item3, iii) => {
												if (index2 === iii) {
													item3.number += 1
												}
											})
										}
									}
								})
							}
						}
					})
				}
			},
			//下一步
			confirm() {
				console.log(8888, this.objdata)
				let _self = this;
				let task_datas = [];
				if (this.objdata) {
					if (this.objdata.list && this.objdata.list.length > 0) {
						this.objdata.list.forEach(item => {
							if (this.selType === 'pop') {
								let task_data = {
									id: '',
									image_name: '',
									product_album_data_id: '',
									mark: '',
									url: '',
									data: []
								}
								task_data.id = '';
								task_data.image_name = '';
								task_data.mark = '';
								task_data.url = item.url;
								task_data.product_album_data_id = item.id;
								if (this.objdata.datalist && this.objdata.datalist.length > 0) {
									this.objdata.datalist.forEach(item2 => {
										task_data.data.push(item2)
									})
								}
								if (this.objdata.datalist && this.objdata.datalist.length > 0) {
									this.objdata.datalist.forEach(item2 => {
										if (item2.data && item2.data.length > 0) {
											item2.data.forEach(item3 => {
												task_data.data.push(item3)
											})
										}
									})
								}
								if (this.objdata.datalist && this.objdata.datalist.length > 0) {
									this.objdata.datalist.forEach(item2 => {
										if (item2.data && item2.data.length > 0) {
											item2.data.forEach(item3 => {
												if (item3.data && item3.data.length > 0) {
													item3.data.forEach(item4 => {
														task_data.data.push(item4)
													})
												}
											})
										}
									})
								}
								task_datas.push(task_data)
							} else if (this.selType === 'prop') {
								let task_data = {
									id: '',
									image_name: '',
									url: '',
									mark: '',
									data: []
								}
								task_data.id = '';
								task_data.image_name = '';
								task_data.mark = '';
								task_data.url = item.url;
								if (this.objdata.datalist && this.objdata.datalist.length > 0) {
									this.objdata.datalist.forEach(item2 => {
										task_data.data.push(item2)
									})
								}
								if (this.objdata.datalist && this.objdata.datalist.length > 0) {
									this.objdata.datalist.forEach(item2 => {
										if (item2.data && item2.data.length > 0) {
											item2.data.forEach(item3 => {
												task_data.data.push(item3)
											})
										}
									})
								}
								task_datas.push(task_data)
							}


						})
					}
				}
				console.log(9999, task_datas)
				if (this.selType === 'pop' || this.selType === 'prop') {
					if (task_datas && task_datas.length > 0) {
						task_datas.forEach(item => {
							if (item.data && item.data.length > 0) {
								item.data.forEach(item2 => {
									if (this.selType === 'pop') {
										delete item2.id;
										delete item2.data;
										delete item2.create_time;
										delete item2.company_id;
										delete item2.delete_time;
										delete item2.name;
										delete item2.next_num;
										delete item2.product_texture_id;
										//delete item2.texture;
										delete item2.type;
										delete item2.update_time;
									} else if (this.selType === 'prop') {
										delete item2.id;
										delete item2.data;
										delete item2.create_time;
										delete item2.company_id;
										delete item2.delete_time;
										delete item2.name;
										delete item2.next_num;
										delete item2.product_texture_id;
										//delete item2.texture;
										delete item2.type;
										delete item2.update_time;
									}
								})
							}
						})
					}
					this.json.task_data = task_datas
					console.log(1234, task_datas)
					saveTaskDatas(this.json).then(res => {
						if (res.code === 2000) {
							uni.showToast({
								title: '保存成功！',
								icon: 'none',
								duration: 2000
							})
							if (_self.selType === 'pop') {
								if(this.addType === 'popadd'){
									this.$util.prePage(2).resdata4();
									setTimeout(() => {
										uni.navigateBack({
											delta: 2,
										})
									}, 500)
								}else{
									this.$util.prePage(3).resdata4();
									setTimeout(() => {
										uni.navigateBack({
											delta: 3,
										})
									}, 500)
								}
								
							} else if (_self.selType === 'prop') {
								this.$util.prePage().resdata4();
								setTimeout(() => {
									uni.navigateBack()
								}, 500)
							}

						}
					})
				}

			},
			//返回
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			//重置筛选
			resetFilterData() {

			},
			//确认筛选
			setFilterData() {

			},
			loadmore() {

			},
			//底部弹窗
			change1(e) {
				if (!e.show) {
					this.showtip = false;
				}
			},
			//取消
			cancel(type) {
				this['show' + type] = false;
				this.show = false;
			},
		}
	}
</script>

<style lang="scss">
	/* 下拉窗口 */
	.popup-content {
		display: flex;
		flex-direction: column;

		.header {
			display: flex;
			border-bottom: 1rpx solid #eee;
			height: 100rpx;

			.title {
				line-height: 100rpx;
				padding: 0 30rpx;
				text-align: left;
				font-size: 32rpx;
				color: #333;
				font-weight: bold;
			}
		}

		.body {
			display: flex;
			max-height: 700rpx;
			flex-direction: column;
			.box-nodata{
				display: flex;
				justify-content: center;
				align-items: center;
				height: 200rpx;
				font-size: 28rpx;
				color: #999;
				margin-right: 50rpx;
			}

			.box {
				display: flex;
				justify-content: center;
				align-items: center;
				height: 100rpx;
				border-bottom: 1rpx solid #eee;
				font-size: 36rpx;

				.box-name {
					margin-right: 30rpx;
				}

				.box-icon {
					width: 34rpx;

					.box-icon-dagou {
						width: 34rpx;
						height: 28rpx;
					}
				}
			}
		}

		.footer {
			height: 100rpx;
			color: $font-color-r;
			font-size: 36rpx;
			text-align: center;
			line-height: 88rpx;
			background: $uni-bg-color;
			margin-right: 50rpx;
		}
	}

	/* 提示窗口 */
	.w-tip {
		/* #ifndef APP-NVUE */
		display: flex;
		flex-direction: column;
		/* #endif */
		width: 100vw;
		min-height: 200rpx;
		border-radius: 20rpx 20rpx 0px 0px;
		background-color: #fff;
		box-shadow: 0rpx 7rpx 7rpx 0rpx rgba(0, 0, 0, 0.1);
		padding: 20rpx 0rpx;
		margin: 30rpx auto 0;

		.w-con {
			line-height: 100rpx;
			font-size: 32rpx;
			font-weight: 400;
			color: $font-color-3;
			text-align: center;

			.w-con-txt {
				border-bottom: 1rpx solid #f5f5f5;
			}

			.w-con-cen {
				color: #198FFF;
			}
		}
	}

	.page-content {
		border-top: 1rpx solid #f5f5f5;
		width: 100vw;
		height: 100%;
		background: $uni-bg-color;

		.page-foot {
			width: 100%;
			position: fixed;
			left: 0;
			right: 0;
			bottom: 0;
			height: 90rpx;
			display: flex;
			flex-shrink: 0;
			flex-direction: row !important;
			align-items: center;
			font-size: 36rpx;
			font-weight: bold;
			line-height: 90rpx;
			color: $font-color-w;

			.submit {
				text-align: center;
				flex: 2;
				background-color: #198FFF;
			}
		}

		.page-body {
			display: flex;
			height: calc(100% - 90rpx);
			padding: 0rpx;

			.body-top {
				display: flex;
				flex-wrap: wrap;
				padding: 40rpx 30rpx 0rpx 30rpx;

				.body-top-add {
					background: $uni-bg-color-grey;
					border-radius: 10rpx;
				}

				.body-top-li {
					margin-right: 14rpx;
					margin-bottom: 14rpx;
					position: relative;

					.top-li-img {
						border-radius: 10rpx;
					}

					.top-li-icon {
						position: absolute;
						top: -14rpx;
						right: -14rpx;
						width: 28rpx;
						height: 28rpx;
					}
				}

				.body-top-li:nth-of-type(6n) {
					margin-right: 0;
				}
			}

			.body-box {
				display: flex;
				flex-direction: column;
				background: $uni-bg-color;
				margin-bottom: 20rpx;

				.li-texture-bot3 {
					width: 84rpx;
					height: 52rpx;
					margin: 10rpx 0 40rpx 30rpx;
				}

			}
		}
	}
</style>
